package main

import (
	"fmt"
	"time"
)

var ticket = 10 //100张票
func main() {
	go saleTickets("售票口1")
	go saleTickets("售票口2")
	go saleTickets("售票口3")
	go saleTickets("售票口4")

	time.Sleep(5 * time.Second)
}

func saleTickets(name string) {
	for {
		if ticket > 0 {
			ticket--
			fmt.Println(name, "售出1张，剩余：", ticket)

		} else {
			fmt.Println("售空了")
			break
		}
	}
}
